package com.bmd.backgroundmanger.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bmd.backgroundmanger.entity.Question;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 题目Mapper接口
 */
@Mapper
public interface QuestionMapper extends BaseMapper<Question> {

    /**
     * 根据分类ID查询题目
     */
    @Select("SELECT * FROM questions WHERE category_id = #{categoryId}")
    List<Question> selectByCategoryId(Integer categoryId);

    /**
     * 根据难度级别查询题目
     */
    @Select("SELECT * FROM questions WHERE difficulty_level = #{difficultyLevel}")
    List<Question> selectByDifficultyLevel(String difficultyLevel);

    /**
     * 搜索题目
     */
    @Select("SELECT * FROM questions WHERE title LIKE CONCAT('%', #{keyword}, '%') OR content LIKE CONCAT('%', #{keyword}, '%')")
    List<Question> searchQuestions(String keyword);
} 